//
//  GroupIDCheckViewController.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/4/5.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "GroupIDCheckViewController.h"

@interface GroupIDCheckViewController ()<UITextViewDelegate>

@property (nonatomic, strong) UIImageView *groupImageV; // 小组头像
@property (nonatomic, strong) UILabel *groupName; // 小组名字
@property (nonatomic, strong) UITextView *IDCheckTF; // 身份验证
@property (nonatomic, strong) UIImageView *friendAlertImageV; // 好友弹窗

@end

@implementation GroupIDCheckViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    // navi的修改
    [self changeNavigation];
    // 视图布局
    [self addMySubview];
    // 添加弹窗
    [self addAlertView];
}

// navi的修改
- (void)changeNavigation
{
   
    [self.navigationController.navigationBar setTranslucent:NO];
    self.navigationItem.title = @"身份验证";
    UIImageView *leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    leftImageView.image = [UIImage imageNamed:@"houtui"];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftImageView];
    UITapGestureRecognizer *leftTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lastPage:)];
    [leftImageView addGestureRecognizer:leftTapGes];
    
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"发送" style:UIBarButtonItemStylePlain target:self action:@selector(send:)];
    rightItem.tintColor = [UIColor whiteColor];
    self.navigationItem.rightBarButtonItem = rightItem;
    
}

#pragma mark - 返回上一页面
- (void)lastPage:(UITapGestureRecognizer *)tapGes
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - 下一步
- (void)send:(UIBarButtonItem *)rightItem
{
    NSLog(@"发送群组请求");
    self.friendAlertImageV.hidden = NO;
}

// 提示框
- (void)addAlertView
{
    
    self.friendAlertImageV = [[UIImageView alloc] initWithFrame:CGRectMake((kScreenWidth - 145) / 2 * kAdjustParamater, 200 * kAdjustParamater, 145 * kAdjustParamater, 132 * kAdjustParamater)];
    self.friendAlertImageV.backgroundColor = [UIColor whiteColor];
    self.friendAlertImageV.userInteractionEnabled = YES;
    self.friendAlertImageV.image = [UIImage imageNamed:@"friendAlert.png"];
    self.friendAlertImageV.hidden = YES;
    [self.view addSubview:_friendAlertImageV];
    
    UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cancelFriendAlert:)];
    [self.friendAlertImageV addGestureRecognizer:tapGes];

    
}

- (void)cancelFriendAlert:(UITapGestureRecognizer *)tapGes
{
    NSLog(@"消失");
    tapGes.view.hidden = YES;
}

#pragma mark - 视图布局
- (void)addMySubview
{
    // 灰色背景
    UIView *grayBackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    grayBackView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.03];
    [self.view addSubview:grayBackView];
    self.groupImageV = [[UIImageView alloc] initWithFrame:CGRectMake(10 * kAdjustParamater, 20 * kAdjustParamater, 50 * kAdjustParamater, 50 * kAdjustParamater)];
    self.groupImageV.backgroundColor = [[UIColor yellowColor] colorWithAlphaComponent:0.5];
    self.groupImageV.layer.cornerRadius = 25 * kAdjustParamater;
    [grayBackView addSubview:_groupImageV];
    
    self.groupName = [[UILabel alloc] initWithFrame:CGRectMake(self.groupImageV.right + 10 * kAdjustParamater, self.groupImageV.top + 15 * kAdjustParamater, 150 * kAdjustParamater, 20 * kAdjustParamater)];
    //   self.friendName.backgroundColor = [UIColor redColor];
    self.groupName.text = @"张国文张国文";
    self.groupName.textAlignment = NSTextAlignmentLeft;
    self.groupName.font = [UIFont systemFontOfSize:k15Big];
    self.groupName.textColor = [UIColor blackColor];
    [grayBackView addSubview:_groupName];
    
    
    self.IDCheckTF = [[UITextView alloc] initWithFrame:CGRectMake(0, self.groupImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 140 * kAdjustParamater)];
    self.IDCheckTF.backgroundColor = [UIColor whiteColor];
    self.IDCheckTF.text = @"我是张国文";
    self.IDCheckTF.delegate = self;
    self.IDCheckTF.textColor = [UIColor blackColor];
    self.IDCheckTF.font = [UIFont systemFontOfSize:k15Big];
    [grayBackView addSubview:_IDCheckTF];
    //    self.grayBackGround = [[UILabel alloc] initWithFrame:CGRectMake(0, self.friendImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 140 * kAdjustParamater)];
    //    self.grayBackGround.backgroundColor = [UIColor whiteColor];
    //    self.grayBackGround.userInteractionEnabled = YES;
    //    [self.view addSubview:_grayBackGround];
    //
    //    self.IDCheckTF = [[UITextField alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 110 * kAdjustParamater, kScreenWidth - 40 * kAdjustParamater, 20 * kAdjustParamater)];
    //    self.IDCheckTF.backgroundColor = [UIColor redColor];
    //    self.IDCheckTF.text = @"我阿斯顿发生地偶发金额就抢我肉发神经哦壹";
    //    self.IDCheckTF.textAlignment = NSTextAlignmentLeft;
    //    self.IDCheckTF.textColor = [UIColor blackColor];
    //    self.IDCheckTF.delegate = self;
    //    self.IDCheckTF.font = [UIFont systemFontOfSize:k14Big];
    //    [self.view addSubview:_IDCheckTF];
    //
    //    CGRect newFrame = self.IDCheckTF.frame;
    //   newFrame.size.height = [[NetStatusHandle shareHandle] adjustHeight:self.IDCheckTF.text size:13 width:kScreenWidth - 40];
    //    self.IDCheckTF.frame = newFrame;
}

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    if ([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }
    return YES;
}

- (void)textViewDidChange:(UITextView *)textView
{
    NSLog(@"textView = %@", textView.text);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
